#Makefile params (edit this part to configure the built process)
EXE       = rilego
DEBUGMODE = no


SRCS	= \
	launcher.c


OBJS       = $(SRCS:.c=.o)

_INC := -D__EXE="\"$(EXE)\""
DEBUG      = -D_DEBUGMODE_


ifeq ($(DEBUGMODE),yes)
CXXFLAGS   = -Wall $(_INC) -g $(DEBUG) -mwindows
else
CXXFLAGS   = -Wall -march=pentium3 -m32 -O2 -fno-strict-aliasing $(_INC) -mwindows
endif

DEP_FILE   = .depend

TOLINK     = -static -static-libgcc -lshlwapi -mwindows

.PHONY: clean

all: $(EXE)
$(EXE): $(OBJS)
	@echo $(LINK) $@
	@windres -J rc -O coff -i resources.rc -o resources.o
	@$(CXX) $^ $(TOLINK) resources.o -o $@

ifneq ($(DEBUGMODE),yes)
	@echo Stripping
	@strip -s $(EXE).exe
endif

.cpp.o:
	@echo Compiling $<
	@$(CXX) $(CXXFLAGS) -c $< -o $@

clean:
	@echo Cleaning all compiled files
	$(RM) $(OBJS)
	$(RM) $(EXE)
	$(RM) $(DEP_FILE)


depend: $(DEP_FILE)
	@echo $(CXXFLAGS)
	@touch $(DEP_FILE)

$(DEP_FILE):
	@echo Makefile - building dependencies in: $@
	@$(CXX) -E -MM $(SRCS) >> $(DEP_FILE)

ifeq (,$(findstring clean,$(MAKECMDGOALS)))
-include $(DEP_FILE)
endif
